Skip to content

Add Flow and TypeScript types for sx prop#1704

Open
mjames-c wants to merge 1 commit into
facebook:mainfrom
mjames-c:mj--stylex-sx-types
Open

Add Flow and TypeScript types for sx prop#1704
mjames-c wants to merge 1 commit into
facebook:mainfrom
mjames-c:mj--stylex-sx-types

Conversation

@mjames-c

@mjames-c mjames-c commented Jun 9, 2026

Copy link
Copy Markdown

What changed / motivation ?

Added sx React prop typings

Linked PR/Issues

Fixes #1360

Screenshots, Tests, Anything Else

Pre-flight checklist

Copilot AI review requested due to automatic review settings June 9, 2026 02:56
@mjames-c mjames-c requested review from mellyeliu and nmn as code owners June 9, 2026 02:56
@meta-cla

meta-cla Bot commented Jun 9, 2026

Copy link
Copy Markdown

Hi @mjames-c!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

@mjames-c is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@mjames-c mjames-c changed the title Add TypeScript types for sx prop Add Flow and TypeScript types for sx prop Jun 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds first-class TypeScript typing support for a React sx prop when using StyleX, and extends the TypeScript tests to validate expected sx behaviors (valid/invalid values and host-only transform rules).

Changes:

  • Introduced StyleXSxProp type and exported it from the StyleX public type surface.
  • Added React type augmentation so intrinsic JSX elements accept an sx prop typed as StyleXSxProp.
  • Expanded TypeScript tests to cover sx usage on host elements, arrays, and invalid cases.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/typescript-tests/src/test1.tsx Adds TS-level usage and negative tests for sx on JSX elements and custom components.
packages/@stylexjs/stylex/src/types/StyleXTypes.js Defines the StyleXSxProp Flow type.
packages/@stylexjs/stylex/src/types/StyleXTypes.d.ts Defines StyleXSxProp in TypeScript and augments React DOM attributes with sx.
packages/@stylexjs/stylex/src/stylex.js Re-exports StyleXSxProp from the StyleX entrypoint.

Comment thread packages/typescript-tests/src/test1.tsx Outdated
Comment thread packages/typescript-tests/src/test1.tsx
Comment thread packages/typescript-tests/src/test1.tsx Outdated
Comment thread packages/typescript-tests/src/test1.tsx
*/

/* eslint-disable no-unused-vars */
/* eslint-disable no-unused-vars, react/no-unknown-property */
@mjames-c mjames-c force-pushed the mj--stylex-sx-types branch from 141b090 to 14f35aa Compare June 9, 2026 03:11
@mjames-c

mjames-c commented Jun 9, 2026

Copy link
Copy Markdown
Author

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

my company (Canva) does have a CLA with Meta but I'm waiting to be added to the list of contributors.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 10, 2026
@meta-cla

meta-cla Bot commented Jun 10, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flow support for sx prop

2 participants